//
//  ModifyNameView.m
//  PigMarket
//
//  Created by Felix on 2019/3/15.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "ModifyNameView.h"

@interface ModifyNameView ()
/**
 昵称输入框背景
 */
@property (nonatomic , strong) UIView *nicknameBg;
/**
 上面提示lab
 */
@property (nonatomic , strong) UILabel *topTipsLab;
/**
 底部提示
 */
@property (nonatomic , strong) UILabel *bottomTipsLab;

@end

@implementation ModifyNameView

#pragma mark - init method
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    // 添加子控件
    [self addSubview:self.topTipsLab];
    [self addSubview:self.nicknameBg];
    [self.nicknameBg addSubview:self.nicknameField];
    [self addSubview:self.bottomTipsLab];
    [self addSubview:self.saveBtn];
}

- (void)initLayout {
    // 布局子控件
    [self.topTipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH - 30);
        make.height.mas_equalTo(34);
    }];
    
    
    [self.nicknameBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.topTipsLab.mas_bottom).offset(0);
        make.height.mas_equalTo(54);
    }];
    
    [self.nicknameField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(54);
    }];
    
    
    [self.bottomTipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(self.nicknameBg.mas_bottom).offset(10);
        make.width.mas_equalTo(SCREEN_WIDTH - 30);
    }];
    
    
    [self.saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.bottomTipsLab.mas_bottom).offset(60);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(48);
        make.bottom.mas_equalTo(0);
    }];
}

#pragma mark - getter and setter

- (UILabel *)topTipsLab {
    if (!_topTipsLab) {
        _topTipsLab = [[UILabel alloc] init];
        _topTipsLab.textColor = [UIColor tipsGrayColor];
        _topTipsLab.font = [UIFont middleFont];
        _topTipsLab.text = @"昵称最多输入10个字符";
    }
    return _topTipsLab;
}


- (UIView *)nicknameBg {
    if (!_nicknameBg) {
        _nicknameBg = [[UIView alloc] init];
        _nicknameBg.backgroundColor = [UIColor whiteColor];
    }
    return _nicknameBg;
}


- (UITextField *)nicknameField {
    if (!_nicknameField) {
        _nicknameField = [[UITextField alloc] init];
        _nicknameField.placeholder = @"请输入昵称";
        _nicknameField.textColor = [UIColor textBlackColor];
        _nicknameField.clearButtonMode = UITextFieldViewModeAlways;
        _nicknameField.backgroundColor = [UIColor whiteColor];
        _nicknameField.font = mFont(15);
    }
    return _nicknameField;
}


- (UILabel *)bottomTipsLab {
    if (!_bottomTipsLab) {
        _bottomTipsLab = [[UILabel alloc] init];
        _bottomTipsLab.text = @"设置后可以让你的朋友更快的找到你";
        _bottomTipsLab.textColor = [UIColor tipsGrayColor];
        _bottomTipsLab.font = [UIFont middleFont];
    }
    return _bottomTipsLab;
}


- (UIButton *)saveBtn {
    if (!_saveBtn) {
        _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_saveBtn setTitle:@"保存" forState:UIControlStateNormal];
        [_saveBtn setBackgroundImage:[UIImage imageNamed:@"login_loginbtn_default"] forState:UIControlStateNormal];
    }
    return _saveBtn;
}
@end
